<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
include "connection.php";
session_start();
$add_admin = $_SESSION['username'];
date_default_timezone_set('prc');

$add_user  = $_REQUEST['addMoneyUserId'];
$add_date  = date('Y-m-d H:i',time());
$add_money = $_REQUEST['addMoney'];
$add_user_name = $_REQUEST['addMoneyUserName'];
$department = $_REQUEST['addMoneyDPM'];

$table = "user";
$result = mysql_query("select * from $table where user_id = '$add_user'");
while ($row = mysql_fetch_array($result)) {
    $now_balance = $row['balance'];
}

$update_money = $now_balance + $add_money;

$sql = "update $table set balance = '$update_money' where user_id = '$add_user'";
$query = mysql_query($sql) or die ("充值失败，请返回！");


$tableAddMoney = "addmoney";
$sqladd = "insert into $tableAddMoney (
add_money_user,
add_money,
add_money_admin,
add_money_date,
add_money_name,
add_money_department
) value (
'$add_user',
'$add_money',
'$add_admin',
'$add_date',
'$add_user_name',
'$department'
)";
$queryadd = mysql_query($sqladd) or die ("充值记录失败，请返回！");


?>

<script type="text/javascript">
    alert("充值已完成，请点击返回继续操作！");
    document.location.href = "../admin_list_control.php";
</script>

</body>
</html>